<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //取出li和里面的内容
        let str = `
    <ul>
        <li>1111</li>
        <li>2222</li>
        <li>3333</li>
        <li>4444</li>
    </ul>
`
        let reg = /<li>(.*)<\/li>/g
        //console.log(str.match(reg))
        //1. 使用捕获exec实现
        // let match = null
        // let list = []
        // while (match = reg.exec(str)) {
        //     console.log(match[1]) //得到子匹配的值
        //     list.push(match[1])
        // }
        // console.log(list) //得到集合，就可以做dom渲染等后续的操作了
        //2. 使用matchAll实现
        //console.log(str.matchAll(reg))
        let iobj = str.matchAll(reg)
        console.log([...iobj])
    </script>
</body>

</html>